#include <iostream>
using namespace std;

/* 学生 */
struct Student
{
  int num;
  char name[20];
  float score;
};

/* 冒泡排序 */
void sort(Student stu[])
{
  struct Student temp;

  for (int i = 0; i < 3 - 1; i++)
  {
    for (int j = i + 1; j < 3; j++)
    {
      if (stu[j].score < stu[i].score)
      {
        temp = stu[i];
        stu[i] = stu[j];
        stu[j] = temp;
      }
    }
  }
}

int main(int argc, char const *argv[])
{
  struct Student stuArr[3] =
      {
          {3, "王五", 100},
          {2, "李四", 90},
          {1, "张三", 80},
      };

  sort(stuArr);

  for (int i = 0; i < sizeof(stuArr) / sizeof(Student); i++)
  {
    cout << "编号：" << stuArr[i].num << "\t\t姓名：" << stuArr[i].name << "\t成绩：" << stuArr[i].score << "\n";
  }

  return 0;
}
